"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _design = require("@discuzq/design");

var _react = _interopRequireDefault(require("react"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

var App = /*#__PURE__*/function (_React$Component) {
  _inherits(App, _React$Component);

  var _super = _createSuper(App);

  function App(props) {
    var _this;

    _classCallCheck(this, App);

    _this = _super.call(this, props);
    _this.state = {
      province: 1,
      city: 1,
      data1: [{
        className: 'year-list',
        itemClassName: 'year-item',
        scrollType: 'year',
        selectIndex: 2,
        listData: [{
          text: '2015',
          dataKey: '2015222'
        }, {
          text: '2016',
          dataKey: '2016222'
        }, {
          text: '2017',
          dataKey: '2017222'
        }, {
          text: '2018',
          dataKey: '2018222'
        }, {
          text: '2019',
          dataKey: '2019222'
        }],
        scrollData: {
          wheel: {
            selectedIndex: 2,
            rotate: 25,
            adjustTime: 33333
          }
        }
      }, {
        className: 'month-list',
        itemClassName: 'month-item',
        scrollType: 'month',
        selectIndex: 2,
        listData: [{
          text: '1月',
          dataKey: '0'
        }, {
          text: '2月',
          dataKey: '1'
        }, {
          text: '3月',
          dataKey: '2'
        }, {
          text: '4月',
          dataKey: '3'
        }, {
          text: '5月',
          dataKey: '4'
        }, {
          text: '6月',
          dataKey: '5'
        }, {
          text: '7月',
          dataKey: '6'
        }]
      }, {
        className: 'data-list',
        itemClassName: 'data-item',
        scrollType: 'day',
        listData: [{
          text: '1日'
        }, {
          text: '2日'
        }, {
          text: '3日'
        }, {
          text: '4日'
        }, {
          text: '5日'
        }, {
          text: '6日'
        }, {
          text: '7日'
        }]
      }],
      data2: [{
        className: 'province-list',
        itemClassName: 'province-item',
        scrollType: 'province',
        selectIndex: 0,
        listData: [{
          text: '省份1',
          dataKey: '省份1',
          className: 'test-class'
        }, {
          text: '省份2',
          dataKey: '省份2',
          className: 'test-class'
        }, {
          text: '省份3',
          dataKey: '省份3',
          className: 'test-class'
        }],
        scrollData: {
          wheel: {
            selectedIndex: 2,
            rotate: 25,
            adjustTime: 33333
          }
        }
      }, {
        className: 'city-list',
        itemClassName: 'city-item',
        scrollType: 'city',
        selectIndex: 0,
        listData: [{
          text: '市区1-1',
          dataKey: '市区1-1',
          className: 'test-class'
        }, {
          text: '市区1-2',
          dataKey: '市区1-2',
          className: 'test-class'
        }, {
          text: '市区1-3',
          dataKey: '市区1-3',
          className: 'test-class'
        }, {
          text: '市区1-4',
          dataKey: '市区1-4',
          className: 'test-class'
        }],
        scrollData: {
          wheel: {
            selectedIndex: 2
          }
        }
      }, {
        className: 'area-list',
        itemClassName: 'area-item',
        scrollType: 'area',
        listData: [{
          text: '区1-1-1',
          dataKey: '区1-1-1',
          className: 'test-class'
        }, {
          text: '区1-1-2',
          dataKey: '区1-1-2',
          className: 'test-class'
        }, {
          text: '区1-1-2',
          dataKey: '区1-1-2',
          className: 'test-class'
        }]
      }]
    };
    return _this;
  }

  _createClass(App, [{
    key: "touchEnd",
    value: function touchEnd(scrollIndex, itemIndex) {
      console.log("touchEnd: scroll\u5E8F\u53F7".concat(scrollIndex));
      console.log("touchEnd: item\u5E8F\u53F7".concat(itemIndex));
    }
  }, {
    key: "touchStart",
    value: function touchStart(scrollIndex) {
      console.log("touchStart: scroll\u5E8F\u53F7".concat(scrollIndex));
    }
  }, {
    key: "renderAfter",
    value: function renderAfter(scrollObj) {
      console.log(scrollObj);
    }
  }, {
    key: "touchEnd2",
    value: function touchEnd2(scrollIndex, itemIndex) {
      console.log("touchEnd: scroll\u5E8F\u53F7".concat(scrollIndex));
      console.log("touchEnd: item\u5E8F\u53F7".concat(itemIndex));

      if (scrollIndex == 'province') {
        var newData = JSON.parse(JSON.stringify(this.state.data2));
        var data = newData[1].listData;

        for (var i = 0; i < data.length; i++) {
          data[i].text = "\u5E02\u533A".concat(itemIndex + 1, "-").concat(i + 1);
          data[i].dataKey = "\u5E02\u533A".concat(itemIndex + 1, "-").concat(i + 1);
        }

        var cityList = newData[2].listData;

        for (var _i = 0; _i < cityList.length; _i++) {
          cityList[_i].text = "\u533A".concat(itemIndex + 1, "-").concat(this.state.city, "-").concat(_i + 1);
          cityList[_i].dataKey = "\u533A".concat(itemIndex + 1, "-").concat(this.state.city, "-").concat(_i + 1);
        }

        newData[0].selectIndex = itemIndex; // newData[0].scrollData.wheel.selectIndex = itemIndex;

        newData[1].selectIndex = this.state.city - 1; // newData[1].scrollData.wheel.selectIndex = itemIndex;

        this.setState({
          province: itemIndex + 1,
          data2: newData
        });
      } else if (scrollIndex == 'city') {
        var _newData = JSON.parse(JSON.stringify(this.state.data2));

        var _data = _newData[2].listData;

        for (var _i2 = 0; _i2 < _data.length; _i2++) {
          _data[_i2].text = "\u533A".concat(this.state.province, "-").concat(itemIndex + 1, "-").concat(_i2 + 1);
          _data[_i2].dataKey = "\u533A".concat(this.state.province, "-").concat(itemIndex + 1, "-").concat(_i2 + 1);
        }

        _newData[0].selectIndex = this.state.province - 1;
        _newData[1].selectIndex = itemIndex;
        this.setState({
          data2: _newData,
          city: itemIndex + 1
        });
      }
    }
  }, {
    key: "touchStart2",
    value: function touchStart2(scrollIndex) {
      console.log("touchStart: scroll\u5E8F\u53F7".concat(scrollIndex));
    }
  }, {
    key: "renderAfter2",
    value: function renderAfter2(scrollObj) {
      console.log(scrollObj);
    }
  }, {
    key: "componentDidMount",
    value: function componentDidMount() {
      this.setState({
        isCSRShow: true
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      return /*#__PURE__*/_react.default.createElement("div", {
        className: "zzc-demo"
      }, /*#__PURE__*/_react.default.createElement("div", {
        className: "zzc-demo-body full"
      }, /*#__PURE__*/_react.default.createElement(_design.WebPicker, {
        onTouchEnd: function onTouchEnd(scrollIndex, itemIndex) {
          _this2.touchEnd(scrollIndex, itemIndex);
        },
        onTouchStart: function onTouchStart(scrollIndex) {
          _this2.touchStart(scrollIndex);
        },
        pickerData: this.state.data1,
        renderAfter: this.renderAfter
      })));
    }
  }]);

  return App;
}(_react.default.Component);

exports.default = App;